﻿<UserControl x:Class="CPPEI.Coolzon.UI.DataPartLib.DataChartSector"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:src="clr-namespace:CPPEI.Coolzon.UI.DataPartLib"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:CPPEI.Coolzon.UI.DataPartLib"
             xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing" 
             mc:Ignorable="d" 
             d:DesignHeight="500" d:DesignWidth="500"
             x:Name="uc">
    <Canvas>
        <ed:Arc x:Name="arcSector" ArcThickness="1" ArcThicknessUnit="Percent"
                Stretch="None" Stroke="Transparent"  
                Fill="{Binding ElementName=uc, Path=FillBrush}"
                StartAngle="{Binding ElementName=uc, Path=ArcStartAngle}" 
                EndAngle="{Binding ElementName=uc, Path=ArcEndAngle}"
                Height="{Binding ElementName=uc, Path=SectorHeight}"  
                Width="{Binding ElementName=uc, Path=SectorWidth}"
                Margin="{Binding ElementName=uc, Path=SectorMargin}" 
                VerticalAlignment="Center"  
                HorizontalAlignment="Center" 
                Panel.ZIndex="2" />
        <Label Canvas.Left="0" Canvas.Top="0" Panel.ZIndex="2" 
                HorizontalContentAlignment="Left"
                VerticalContentAlignment="Center"
                RenderTransformOrigin="0.5,0.5"
                Width="{Binding ElementName=uc, Path=Width}"
                Height="{Binding ElementName=uc, Path=Height}"
                Padding="{Binding ElementName=uc, Path=ValueLabelPadding}">
            <Label.RenderTransform>
                <RotateTransform Angle="{Binding ElementName=uc, Path=ArcMiddleAngle}"/>
            </Label.RenderTransform>
            <Label.Content>
                <StackPanel Orientation="Vertical" RenderTransformOrigin="0.5,0.5">
                    <TextBlock x:Name="nameContentLabel"
                       TextWrapping="Wrap"
                       HorizontalAlignment="Center"
                       Text="{Binding ElementName=uc, Path=DataItemName}"
                       FontSize="{Binding ElementName=uc, Path=FontSize}"
                       Foreground="{Binding ElementName=uc, Path=Foreground}"
                       FontFamily="{Binding ElementName=uc, Path=FontFamily}" 
                       FontWeight="{Binding ElementName=uc, Path=FontWeight}"
                Visibility="{Binding  ElementName=uc, Path=ItemNameVisible}">
                    </TextBlock>
                    <TextBlock x:Name="contentLabel"
                       TextWrapping="Wrap"
                       Text="{Binding ElementName=uc, Path=DataItemValue}"
                       FontSize="{Binding ElementName=uc, Path=FontSize}"
                       Foreground="{Binding ElementName=uc, Path=Foreground}"
                       FontFamily="{Binding ElementName=uc, Path=FontFamily}" 
                       FontWeight="{Binding ElementName=uc, Path=FontWeight}"
                Visibility="{Binding  ElementName=uc, Path=ItemValueVisible}" >
                    </TextBlock>
                    <StackPanel.RenderTransform>
                        <RotateTransform Angle="{Binding ElementName=uc, Path=ArcNegativeMiddleAngle}"/>
                    </StackPanel.RenderTransform>
                </StackPanel>
            </Label.Content>
        </Label>
        <Line x:Name="nameLine" Stroke="White" X1="250" Y1="250" X2="0" Y2="250" RenderTransformOrigin="1,1" Panel.ZIndex="1"
              Visibility="{Binding  ElementName=uc, Path=LineVisible}">
            <Line.RenderTransform>
                <RotateTransform Angle="{Binding ElementName=uc, Path=ArcMiddleAngle}"></RotateTransform>
            </Line.RenderTransform>
        </Line>

        <ed:Arc x:Name="arcRing" ArcThickness="50" ArcThicknessUnit="Pixel" Height="100"  Stretch="None" Stroke="Transparent"  Width="100" Fill="#BBFFFFFF" HorizontalAlignment="Center" VerticalAlignment="Center" Panel.ZIndex="5"
                StartAngle="{Binding ElementName=uc, Path=ArcStartAngle}"
                 EndAngle="{Binding ElementName=uc, Path=ArcEndAngle}">
        </ed:Arc>
        <Label x:Name="indexLabel" Canvas.Left="0" Canvas.Top="0"  VerticalContentAlignment="Center" HorizontalContentAlignment="Right" Panel.ZIndex="6"
               Height="500"
               Width="250"
               Visibility="Collapsed">
            <Label.RenderTransform>
                <RotateTransform
                    Angle="{Binding ElementName=uc, Path=ArcMiddleAngle}"
                    CenterX="{Binding ElementName=uc, Path=CenterX}"
                    CenterY="{Binding ElementName=uc, Path=CenterY}"/>
            </Label.RenderTransform>
            <Label.Content>
                <Label x:Name="indexContentLabel"  Content="{Binding ElementName=uc, Path=IndexValue}"  FontSize="14"  Foreground="Black" FontWeight="Bold" RenderTransformOrigin="0.5,0.5">
                    <Label.RenderTransform>
                        <RotateTransform Angle="{Binding ElementName=uc, Path=ArcNegativeMiddleAngle}"/>
                    </Label.RenderTransform>
                </Label>
            </Label.Content>
        </Label>
    </Canvas>
</UserControl>
